//
//  DrawUtils.h
//  Ikinloop-demo
//
//  Created by Li Shen on 2021/4/22.
//  Copyright © 2021 lyh. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface DrawUtils : NSObject

@property (nonatomic, strong) UIColor *drawerColor;

@property (nonatomic, strong) CAShapeLayer *shapelayer;
//贝塞尔曲线路径
@property (nonatomic, strong)UIBezierPath *bezierpath;

- (instancetype)initWithLayer:(CALayer *)layer;
- (instancetype)initWithContext:(CGContextRef)context;
- (instancetype)initWithLayer:(CALayer*)layer context:(CGContextRef)context;

- (void)setCGContextRef:(CGContextRef)context;

- (void)drawLineLineToPoint:(CGPoint)endPoint withLineWidth:(CGFloat)lineWidth;

- (void)drawLineStartPoint:(CGPoint)startPoint toEndPoint:(CGPoint)endPoint withLineWidth:(CGFloat)lineWidth;

- (void)addLineToBezierpath:(UIBezierPath *)bezierpath toEndPoint:(CGPoint)endPoint withLineWidth:(CGFloat)lineWidth;

- (void)beginBezierpath:(UIBezierPath*)bezierpath color:(UIColor*)color lineWidth:(CGFloat)lineWidth lineCap:(CGLineCap)lineCap lineJoin:(CGLineJoin)lineJoin;

- (void)addShapelayer:(CAShapeLayer *)shapelayer withBezierpath:(UIBezierPath *)bezierpath withColor:(UIColor*)color;
- (void)addBezierpath:(CAShapeLayer *)shapelayer withBezierpath:(UIBezierPath *)bezierpath withColor:(UIColor*)color;


- (void)clearRect:(CGFloat)x y:(CGFloat)y width:(CGFloat)width height:(CGFloat)height;
+(CGFloat) mm2pt:(CGFloat)mm;
+(CGFloat) pt2mm:(CGFloat)pt;

- (void)beginPath:(UIColor*)color lineWidth:(CGFloat)lineWidth lineCap:(CGLineCap)lineCap lineJoin:(CGLineJoin)lineJoin;
- (void)endPath;
- (void)drawLine:(CGPoint)start end:(CGPoint)end;
- (void)moveTo:(CGPoint)point;
- (void)lineTo:(CGPoint)point;
- (void)fill:(UIColor*)color;
- (void)clearRect:(CGRect)rect;
- (void)fillRect:(CGRect)rect color:(UIColor*)color;
@end

NS_ASSUME_NONNULL_END
